package com.hnust.dao;


import com.hnust.domain.ClassInformation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface TeacherClassDao {
    //根据老师id，考试id查询考试班级
    //(老师班级表的班级id=考试班级组的班级id,考试班级组的班级id=班级表的班级id,老师班级表的老师id与考试班级组的的考试id)
    @Select("SELECT class.*\n" +
            "FROM tea_cla tc, test_class_group tcg, class\n" +
            "WHERE tc.tea_id = #{tea_id} AND tcg.testid = #{testid} AND tc.cla_id = tcg.cla_id AND tcg.cla_id = class.cla_id")
    @ResultType(ClassInformation.class)
    List<ClassInformation> queryClassByTestIDTeaId(String tea_id, String testid);

    //根据班级id查询专业名称
    @Select("SELECT major.name\n" +
            "            FROM major, class\n" +
            "            WHERE class.maj_id = major.maj_id  AND class.cla_id = #{cla_id}")
    @ResultType(String.class)
    String queryMajorNameByClassId(String cla_id);

//  根据专业名称找到班级id
    @Select("SELECT class.cla_id\n" +
            "           FROM major, class\n" +
            "           WHERE major.name = #{majorname} AND major.maj_id = class.maj_id AND class.grade = #{classgrade} AND class.cla_number = #{classnumber}")
    @ResultType(String.class)
    String queryClassIdByClassName(String classgrade,String majorname,String classnumber);

//    根据班级名称查询班级id
//    @Select("SELECT cla_id\n" +
//            "       FROM class\n" +
//            "       WhERE class.maj_id = {majid} AND class.grade = {classgrade} AND class.cla_number = {classnumber}"
//    )
//    @ResultType(String.class)
//    String queryClassIdByClassName(String cla_name);

}
